﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.Plumbing
{
	public partial class FormLayCheckMouth : System.Windows.Forms.Form
	{
		public FormLayCheckMouth()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			base.Icon = Resource.YArchitechIcon;
		}

		private void FormLayCheckMouth_Load(object sender, EventArgs e)
		{
			string autoDesignSetting = this.userSetting.GetAutoDesignSetting("laycheckmouth");
			this.SettingSelectedStyle(autoDesignSetting);
		}

		private void SettingSelectedStyle(string styelName)
		{
			if (styelName == "铸铁")
			{
				this.rdbIron.Checked = true;
				this.rdbPVC.Checked = false;
				this.rtxtRuler.Text = this.ironStyle;
				return;
			}
			this.rdbIron.Checked = false;
			this.rdbPVC.Checked = true;
			this.rtxtRuler.Text = this.pvcStyle;
		}

		private void btnLay_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Yes;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void FormLayCheckMouth_FormClosing(object sender, FormClosingEventArgs e)
		{
			string nodeValue = "铸铁";
			if (this.rdbPVC.Checked)
			{
				nodeValue = "塑料";
			}
			if (this.rdbIron.Checked)
			{
				nodeValue = "铸铁";
			}
			this.userSetting.WriteAutoDesignSetting("laycheckmouth", nodeValue);
		}

		private void rdbIron_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdbIron.Checked)
			{
				this.rtxtRuler.Text = this.ironStyle;
			}
			if (this.rdbPVC.Checked)
			{
				this.rtxtRuler.Text = this.pvcStyle;
			}
		}

		public int GetLayStyle()
		{
			int result = 5;
			if (this.rdbPVC.Checked)
			{
				result = 5;
			}
			if (this.rdbIron.Checked)
			{
				result = 2;
			}
			return result;
		}

		private HVACUserSetting userSetting = new HVACUserSetting();

		private string ironStyle = "布置规则：隔层布置一个检查口";

		private string pvcStyle = "布置规则：每六层布置一个检查口";
	}
}
